home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Tools & Apps / Misc. Utilities / Installer / Installer 3.2 / Samples - Installer 3.2 / ActionAtomSample.c next >
Encoding:
C/C++ Source or Header  |  1992-01-22  |  2.3 KB  |  81 lines  |  [TEXT/MPS ]

  1. /*------------------------------------------------------------------------------
  2.  *
  3.  *    Apple Macintosh Developer Technical Support
  4.  *
  5.  *  Installer 3.1 sample: Action Atoms
  6.  *
  7.  *    File:        ActionAtomSample.c -    c Source
  8.  *
  9.  *    by:            Jon Zap
  10.  *
  11.  *    Copyright © 1990-1991 Apple Computer, Inc.
  12.  *    All rights reserved.
  13.  *
  14.  *----------------------------------------------------------------------------*/
  15. #if 0
  16. c -b ActionAtomSample.c
  17. Link -ra =resPurgeable -rt infn=1001 -rn -m ACTIONATOM -t rsrc -c RSED ∂
  18.         ActionAtomSample.c.o ∂
  19.         -o ActionAtomSample.rsrc
  20. #endif
  21.  
  22. #include <Traps.h>
  23. #include <Types.h>
  24. #include <QuickDraw.h>
  25. #include <Memory.h>
  26. #include <Files.h>
  27. #include <Resources.h>
  28. #include <Dialogs.h>
  29. #include <StandardFile.h>
  30. #include <ActionAtomIntf.h>
  31. #include "ActionAtomSelectors.h"
  32.  
  33. #define NIL 0
  34.  
  35. Boolean AlertAtom();
  36.  
  37. pascal Boolean ACTIONATOM(AAPBRecPtr AB)
  38. {
  39.     switch (AB->aaRefCon) {    /* switch is useless here but we assume that we'll add other userFunctions */
  40.     
  41.     case ShowAlertSelector: 
  42.         return AlertAtom();
  43.     }
  44. }
  45.  
  46. Boolean AlertAtom()
  47. {
  48.     unsigned short    screenWidth,screenHeight,alertWidth, alertHeight;
  49.     GrafPtr            myPort,thePort;
  50.     Rect            alertRect,t;
  51.     AlertTHndl        theAlert;
  52.     
  53.  
  54.     GetPort(&myPort);                                        // save Installer GrafPort
  55.     
  56.     theAlert = (AlertTHndl) GetResource('ALRT',128);        // get the alert template
  57.     HLock ((Handle)theAlert);                                // don't want to lose it
  58.     alertRect = *(Rect *)*theAlert;
  59.     alertWidth = alertRect.right - alertRect.left;                // calculate alert width
  60.     alertHeight = alertRect.bottom - alertRect.top;                // calculate alert height
  61.  
  62.     GetWMgrPort(&thePort);                                    // get desktop window port
  63.     t = thePort->portRect;
  64.     screenWidth = t.right - t.left;                                // calc screen width
  65.     screenHeight = t.bottom - t.top;                                // and height
  66.  
  67.     alertRect.left = t.left + ((screenWidth - alertWidth) >> 1);        // center alert on screen. calc new left.
  68.     alertRect.right = alertRect.left + alertWidth;                // calc new right
  69.     alertRect.top = 10 + t.top + ((screenHeight - alertHeight) >> 1);// calc new top
  70.     alertRect.bottom = alertRect.top + alertHeight;                // calc new bottom
  71.     *(Rect *)*theAlert = alertRect;
  72.  
  73.     (void) NoteAlert(128,NIL);                                // do alert
  74.     HUnlock ((Handle)theAlert);                                // free it up
  75.     DetachResource((Handle)theAlert);                        // don't re-write ALRT with new rectangle
  76.  
  77.     SetPort(myPort);                                        // give the port back
  78.     return true;
  79.         
  80. }
  81.